package com.framework.seedkit.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseFragment extends Fragment implements BaseViewInterface {
	protected Context mContext = null;
    protected LayoutInflater mInflater;
	protected View view = null;
	public String tag;
	private Unbinder unbinder;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.mContext = getActivity();
		tag = this.getClass().getSimpleName();
	}

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		view = inflater.inflate(getLayoutId(), container,
				false);
		unbinder = ButterKnife.bind(this, view);

		initView();
		initData();

		return view;
	}

	@Override
	public void initView() {

	}

	@Override
	public void initData() {

	}

	protected int getLayoutId() {
        return 0;
    }

    protected View inflateView(int resId) {
        return this.mInflater.inflate(resId, null);
    }

	@Override
	public void onDestroyView() {
		unbinder.unbind();

		super.onDestroyView();
	}

	@Override
	public void onDetach() {
		super.onDetach();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

}
